define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'goods/server/index' + location.search,
                    add_url: 'goods/server/add',
                    edit_url: 'goods/server/edit',
                    // del_url: 'goods/server/del',
                    multi_url: 'goods/server/multi',
                    import_url: 'goods/server/import',
                    table: 'server',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'service', title: __('Service'), operate:'BETWEEN'},
                        {field: 'trade', title: __('Trade'), operate:'BETWEEN'},
                        {field: 'safe', title: __('Safe'),searchList: {"1":__('找回包赔'),"2":__('无服务'),"3":__('心意购')}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'type', title: __('Type'),searchList: {"1":__('账号'),"2":__('金币')}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'method', title: __('Method'),searchList: {"1":__('平台代发'),"2":__('卖家发货')}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'xyg', title: __('买家是否选择'),searchList: {"1":__('否'),"2":__('是')}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
